package com.jenkins.test.proxy.gov.proxy;

import org.springframework.beans.factory.FactoryBean;

/**
 * @version V1.0.0
 * @ClassName: {@link GovStandardServiceProxyFactory}
 * @Description: GovStandardServiceProxyFactory
 * @author: Lanzhou
 * @date: 2022/1/22 17:04
 * @Copyright:2020 All rights reserved.
 */
public class GovStandardServiceProxyFactory<T> implements FactoryBean<T> {

    /**
     * 代理dao 接口的class
     */
    private Class<T> interfaceClass;

    public Class<T> getInterfaceClass() {
        return interfaceClass;
    }

    public void setInterfaceClass(Class<T> interfaceClass) {
        this.interfaceClass = interfaceClass;
    }

    @SuppressWarnings("unchecked")
    @Override
    public T getObject() throws Exception {
        return (T) new GovStandardServiceProxy<T>().bind(interfaceClass);
    }

    @Override
    public Class<?> getObjectType() {
        return interfaceClass;
    }

    @Override
    public boolean isSingleton() {
        // 单例模式
        return true;
    }


}
